package com.weixinli.utils;

import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;

import javax.servlet.http.HttpSession;

import com.weixinli.utils.SessionAttributeName;
public class MyTimer {
	private TimerTask task=null;
	private Timer timer=new Timer();
	
	public void getTimeer(final Map<String,Object> session)
	{
		task=new TimerTask() {
			@Override
			public void run() { 
				session.put(SessionAttributeName.CHECKCODE,"");  //清除session 中的验证码
				session.remove(SessionAttributeName.CHECKCODE);  //移除节点
			}
		};
		timer.schedule(task, 2*1000*60);   //定时多久执行一次
	}
	public void closeTimer() {
		if(timer!=null)
		{
			timer.cancel();
		}
		if(task!=null)
		{
			task.cancel();
		}
	}
	
}
